package com.woniuxy.produce.listener;

import com.woniuxy.produce.service.FinanceSkuService;
import lombok.AllArgsConstructor;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

//@RabbitListener(queues = "sku.queue")
@Component
@AllArgsConstructor
public class ProductListener {


    public static final String SKU_QUEUE = "sku.queue";

    private FinanceSkuService skuService;

    @RabbitListener(queues = SKU_QUEUE)
    public void sku(String skuId){
        skuService.updateSku(Long.valueOf(skuId));
    }

    /**
     * 库存回滚，加库存
     */
    @RabbitListener(queues = "rollback.sku.queue")
    public void rollbackSku(String skuId){
        skuService.rollbackSku(skuId);
    }
}
